package com.lottery.material.dao.portal.portaluser;

import com.lottery.material.dao.base.BaseDao;
import com.lottery.material.entity.portaluser.FollowInfo;
import com.lottery.material.entity.portaluser.PortalUserInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @Author 肖拔赟
 * @Description 用户关注
 * @DATE Created on 2019-04-04 9:31
 */
@Repository
public interface FollowInfoDao extends BaseDao<FollowInfo, Integer> {

    /**
     * @Author 肖拔赟
     * @Description 分页查询关注的用户信息
     * @Date Created on 2019-04-04 15:20
     * @param  userId
     * @return Pageable 分页对象
     */
    //@Query(value = "select us from material_portal_user_info us, material_follow_info fo where 1=1 and  us.userId = fo.followUserId and fo.userId =:userId ")
    @Query(value = "select us from PortalUserInfo us, FollowInfo fo where 1=1 and  us.userId = fo.followUserId and fo.userId =:userId ")
    Page<PortalUserInfo> findFollowByUserId(@Param("userId") String userId, Pageable pageable);

    FollowInfo findByUserIdAndFollowUserId(String userId,String followUserId);

}
